<template>
  <div class="hello">
    <!-- 模板语法，  -->
    <h1>{{ msg }}</h1>
    <div v-html="htmlStr"></div>
    <div v-bind:id="test"></div>
    <button @click="handleClick($event)">click me</button>

    <button @click.prevent="handleClick($event)">click me 2</button>
    <button @click="$emit('patch')">click me 3</button>
    <button @click.prevent.stop="handleClick($event)">click me 2</button>
    <input type="text" @keyup.13="handleKeyup" />

    <slot name="m"></slot>
    <slot name="n" />
  </div>
</template>
// test

<script>
/*
  Vue 会将 data 中的数据 和 Props 中会将其映射到上下文 this 上；
*/
export default {
  name: "HelloWorld",
  data: function() {
    return {
      htmlStr: "<span>fuck</span>",
      test: "test"
    };
  },
  props: {
    msg: String
  },
  methods: {
    handleClick: function(e) {
      console.log(this.msg);
      console.log(e);
    },
    handleKeyup: function() {
      console.log("enter");
    }
  }
};
</script>

<!--
  slot => 插槽的设计；
  自定义事件： 父子组件的通信方式；
-->
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
